package validation;


import dbmanager.DBManager;


/**
 * @author POOL
 *  This Class is used to check the Length of String is equals to given Length
 *  This Class is used in POOL as Validation Object
 * */

public class Fixlength implements Validation
{
	
	DBManager db;
	
	String validationvalue;
	/**
	 * setDbmanager(DBmanager db) method used to assign the DBmanager's Object 
	 * @param db is Object of DBManager Class
	 * @return void
	 */
	public void setDbmanager(DBManager db)
	{
		this.db=db;
	}
	
	/**
	 * getMessage() get the Message of validation 
	 * @return Message
	 */
	
	public String getMessage()
	{
		return " Length should be " +(validationvalue) + " chars";
	}

	public boolean validate(String Value) 
	{
		return false;
	}
	
	public boolean validate(String Value, String ConditionValue)
	{
	try 
		{
			this.validationvalue =ConditionValue; 
			int length = Integer.parseInt(ConditionValue);
			if(length==Value.length())
				return true;
		}
		catch (Exception e) 
		{
			e.printStackTrace();
			return false;
		}
		return false;
	}
	
	public boolean validate(String Value, String ConditionValue, String Refvalue) 
	{
		return validate(Value, ConditionValue);
	}
	
	public void setBasicvalue(String value) 
	{
		
	}
	public static void main(String[] args) 
	{
	Fixlength fix = new Fixlength();
		System.out.println("Result "+fix.validate("acr", "3"));
		System.out.println(fix.getMessage());
		
	}
}
